/**
 * 
 */
package ua.kiev.ntukpi.asu.ga.gui;

import java.util.ArrayList;
import java.util.List;

import ua.kiev.ntukpi.asu.ga.Individual;

/**
 * @author Alexander Galibey
 *
 */
public class PopulationGUIUpdater {

	private MainFrame frame;
	
	public PopulationGUIUpdater(MainFrame frame) {
		super();
		this.frame = frame;
	}
	
	public void update(List<Individual> population){
		
		PairsHolder paintHolder = frame.getPaintHolder();
		
		List<Individual> diedList = new ArrayList<Individual>(paintHolder.getIndividuals());
		diedList.removeAll(population);
		
		List<Individual> bornList = new ArrayList<Individual>(population);
		bornList.removeAll(paintHolder.getIndividuals());
		
		paintHolder.removeAll(diedList);
		
		paintHolder.addAll(bornList);
		
		frame.repaint();
		
	}
	
	
	
}
